package com.jqq.homework;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 姬倩倩
 * @version 1.0
 */
public class Homework03 {
    public static void main(String[] args) {
        //按空格分割字符串 得到字符串数组
        //用String.format()方法输出
        //str[0][1][2] -> str[2] str[0] str1[1].charAt(0)
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入英文名字：");
        String name = scanner.nextLine();
        printName(name);
    }
    public static void printName(String name){
        if(name == null){
            System.out.println("name不能为null");
        }
        String[] names = name.split(" ");
        if(names.length != 3){
            System.out.println("输入的字符串格式不对");
            return;
        }
        System.out.println(String.format("%s,%s .%c",names[2],names[0],names[1].charAt(0)));
    }
}
